package com.tuling.mall.user.ribbon.controller;

import com.tuling.mall.common.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RequestMapping("/user")
@RestController
public class UserController {

    @Autowired
    private RestTemplate restTemplate;


    @RequestMapping("/findOrder/{userId}")
    public R findOrderByUserId(@PathVariable("userId") Integer userId) {

        String url = "http://mall-order/order/findOrderByUserId/" + userId;

        ResponseEntity<R> entity = restTemplate.getForEntity(url, R.class);

        System.out.println("entity = " + entity.getBody());
        System.out.println("entity = " + entity.getHeaders());

        return R.success();
    }

}
